home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / useBookmark.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  3.9 KB  |  119 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  October 24, 1996
  22. //  Author:         mm
  23. //
  24. //  Description:
  25. //      This a helper script which will add a given bookmark
  26. //        to the mainListConnection of an editor.
  27. //
  28. //  Input Arguments:
  29. //      The name of the editor to modify
  30. //        The name of the bookmark to connect
  31. //        Flag to indicate use or detach
  32. //
  33. //  Return Value:
  34. //      None.
  35. //
  36.  
  37. global proc
  38. useBookmark (string $editor, string $bookmark, int $use)
  39. {
  40.     // Make sure the editor exists
  41.     //
  42.     if (!`editor -exists $editor`) {
  43.         error "Editor not found";
  44.     }
  45.     // And make sure the bookmark exists
  46.     //
  47.     if (catch (`sets -query -text $bookmark`)) {
  48.         error "Bookmark not found";
  49.     }
  50.     // First, find out what is connected to this editor
  51.     //
  52.     string $mainListConnection = `editor -query -mainListConnection $editor`;
  53.     // Then check to see if this is already connected to the bookmark
  54.     //
  55.     string $objectConnection;
  56.     if ($mainListConnection != "") {
  57.         $objectConnection = `selectionConnection -findObject $bookmark -query $mainListConnection`;
  58.     }
  59.     // See if we want to use this bookmark, or disconnect it
  60.     //
  61.     if ($use) {
  62.         if ($objectConnection == "") {
  63.             // Create a selection connection to wrap this bookmark
  64.             //
  65.             string $connection = `selectionConnection -object $bookmark -parent $editor`;
  66.             // And attach it to the editor
  67.             //
  68.             string $id;
  69.             if ($mainListConnection != "") {
  70.                 $id = `selectionConnection -query -identify $mainListConnection`;
  71.             }
  72.             if (($mainListConnection == "") || (($id != "listList") && ($id != "objectList"))) {
  73.                 // We can attach it directly
  74.                 //
  75.                 editor -edit -mainListConnection $connection $editor;
  76.             }
  77.             else if (($id == "listList") && !`selectionConnection -query -switch $mainListConnection`) {
  78.                 // There is a list connection that we can attach to
  79.                 //
  80.                 selectionConnection -edit -add $connection $mainListConnection;
  81.             }
  82.             else {
  83.                 // Create a new list connection
  84.                 //
  85.                 string $listConnection = `selectionConnection -connectionList -parent $editor`;
  86.                 editor -edit -mainListConnection $listConnection $editor;
  87.                 if ($id == "objectList") {
  88.                     selectionConnection -edit -add $mainListConnection $listConnection;
  89.                 }
  90.                 selectionConnection -edit -add $connection $listConnection;
  91.             }
  92.         }
  93.     }
  94.     else {
  95.         if ($objectConnection != "") {
  96.             if ($objectConnection == $mainListConnection) {
  97.                 toggleAutoLoad $editor true;
  98.             }
  99.             else {
  100.                 if ($mainListConnection != "") {
  101.                     // Remove the objectConnection from the list connection
  102.                     //
  103.                     selectionConnection -edit -remove $objectConnection $mainListConnection;
  104.                     // Check to see if there is anything else still connected
  105.                     //
  106.                     string $id = `selectionConnection -query -identify $mainListConnection`;
  107.                     if ($id == "listList") {
  108.                         string $list[] = `selectionConnection -query -connectionList $mainListConnection`;
  109.                         if (size ($list) <= 1) {
  110.                             toggleAutoLoad $editor true;
  111.                         }
  112.                     }
  113.                 }
  114.             }
  115. //            deleteUI $objectConnection;
  116.         }
  117.     }
  118. }
  119.